#pragma once

#include "iasyncsendqueue.h"
#include <concrt.h>
#include <unordered_map>

class CAsyncSendQueueForSelectModel :
	public IAsyncSendQueue
{
protected:
	Concurrency::critical_section			m_sendLock;

	typedef std::tr1::unordered_map<SOCKET, std::list<IStreamBuffer*> >	SEND_QUEUE;
	SEND_QUEUE								m_sendQueueBySocket;
	DISCONNECT_FUNCTOR						m_disconnectFunctor;

	virtual bool	coreSend( SOCKET socket, IStreamBuffer& stream );
public:
	CAsyncSendQueueForSelectModel(DISCONNECT_FUNCTOR disconnectFunctor);
	virtual ~CAsyncSendQueueForSelectModel(void);

	virtual bool	Send( SOCKET socket, IStreamBuffer& stream) override;
	virtual bool	Send( SOCKET socket, size_t bytesSent ) override;
	virtual void	Release() override;
};

